package pl.edu.mimuw.irs.rcp.controller.editor.workflow.part;

import org.eclipse.gef.EditPart;

import pl.edu.mimuw.irs.core.model.design.net.IRSActivity;
import pl.edu.mimuw.irs.core.model.design.net.IRSArc;
import pl.edu.mimuw.irs.core.model.design.net.IRSPlace;
import pl.edu.mimuw.irs.core.model.design.net.IRSRequirement;
import pl.edu.mimuw.irs.core.model.design.net.IRSTransition;
import pl.edu.mimuw.irs.core.model.design.net.IRSWorkflow;
import pl.edu.mimuw.irs.core.model.petrinet.Arc;
import pl.edu.mimuw.irs.core.model.petrinet.Place;
import pl.edu.mimuw.irs.core.model.petrinet.Transition;
import pl.edu.mimuw.irs.core.model.petrinet.workflow.Workflow;

/**
 * @author Jakub Rauch
 * Created on: 2009-05-16
 */
public class EditPartFactory implements org.eclipse.gef.EditPartFactory {
	
	// *** Attributes

	// *** Methods
	
	@Override
	public EditPart createEditPart(EditPart context, Object model) {
		EditPart editPart = null;
		if (model instanceof IRSRequirement){
			//Specific RESOURCE SET edit part instance for IRSResourceSet element
			editPart = new IRSRequirementEditPart();
			editPart.setModel(model);
		} else if(model instanceof IRSPlace){
			//Standard edit part instance for IRSPlace element
			editPart = new IRSPlaceEditPart();
			editPart.setModel(model);
		} else if(model instanceof IRSActivity){
			//Specific ACTIVITY edit part instance for IRSActivity element
			editPart = new IRSActivityEditPart();
			editPart.setModel(model);
		} else if(model instanceof IRSTransition){
			//Standard edit part instance for IRSTransition element
			editPart = new IRSTransitionEditPart();
			editPart.setModel(model);
		} else if(model instanceof IRSArc){
			//Standard edit part instance for IRSArc element
			editPart = new IRSArcEditPart();
			editPart.setModel(model);
		} else if(model instanceof IRSWorkflow){
			//Root instance of edit part for root model element
			editPart = new IRSWorkflowEditPart();
			editPart.setModel(model);
		} else if(model instanceof Place){
			//Standard edit part instance for IRSPlace element
			editPart = new PlaceEditPart();
			editPart.setModel(model);
		} else if(model instanceof Transition){
			//Standard edit part instance for IRSTransition element
			editPart = new TransitionEditPart();
			editPart.setModel(model);
		} else if(model instanceof Arc){
			//Standard edit part instance for IRSArc element
			editPart = new ArcEditPart();
			editPart.setModel(model);
		} else if(model instanceof Workflow){
			//Standard edit part instance for IRSArc element
			editPart = new WorkflowEditPart();
			editPart.setModel(model);
		}
		return editPart;
	}
}
